package ink.lovejinhu.leetcodeMatch;

import java.util.Arrays;

/**
 * @author jinhu
 * created 2021-08-01 10:45
 */
public class Solution_5831 {
    public long numberOfWeeks(int[] milestones) {
        Arrays.sort(milestones);
        long max = 0;
        for (int i = 0; i < milestones.length - 1; i++) {
            max += milestones[i];
        }
        if (max >= milestones[milestones.length - 1]) return max + milestones[milestones.length - 1];
        else {
            return max * 2 + 1;
        }
    }

    public static void main(String[] args) {
        int[] res = {1, 2, 3};
        Arrays.sort(res);
        for (int i = 0; i < res.length; i++) {
            System.out.println(res[i]);

        }
    }
}
